#coding=utf-8
import time
import unittest
from appium import webdriver
from Public import BasePage
from TestCase.loginEgovaMobile import login_factory
from TestCase import lanuch_exit
from TestCase import NewRecReport
from TestCase import HTMLTestRunner
from TestCase import Owner
from TestCase import MessageBar
from TestCase import today_tip
from TestCase import General_query
from TestCase import announcement
from TestCase import my_work
from TestCase import SpecialInspect
from TestCase import SelfDeal
from TestCase import Coordinate_query
from TestCase import PatrolManagement
from TestCase import DisposeCase
from TestCase import Comprehensive_Evaluation
from TestCase import Personnel_monitor
from TestCase import Leader_Assign
from TestCase import Case_Supervise
from TestCase import InspectorCheck
from TestCase import contactor
from TestCase import map_test
from TestCase import report_evaluation
# from TestCase import supervisor_allocation
from TestCase import illegal_reporting
from TestCase import Illegal_Check
from TestCase import Illegal_Verification
from TestCase import Illegal_Patrol
import random
from Tool.usefulTools import userfulToolsFactory
from Public import CaseExcelOperate
import sys
from TestCase import VerifyCheck
from Public import resultOprate
import settings

reload(sys)
sys.setdefaultencoding('utf8')

server_url = "http://192.168.101.14:8080/eUrbanMIS"
# user_name = '测试0607'
# user_pwd = ''
# base_dir =  'D://Cruise//pythonSrc//reprot//'

#实例化基础数据
loginDevices = login_factory()
lanuch_exit_app = lanuch_exit.lanuch_exit_factory()
newRecReport = NewRecReport.rec_report_factory()
userfulTool = userfulToolsFactory()
baseFunctionInstance = BasePage.BasicAction()
baseInstance = BasePage.Base()
rec_verify_check = VerifyCheck.RecVerifyCheck()
rec_verify_check_module_instances = VerifyCheck.Verify_Checkt_Module()
case_assistant = MessageBar.message_bar_factory()
owner_center = Owner.Personal_Center()
todaytips = today_tip.today_tip_factory()
mapselect = map_test.map_select_factory()
generalquery = General_query.general_query_factory()
announcements = announcement.doc_announcement_factory()
mywork = my_work.my_work_factory()
specialinspect = SpecialInspect.special_inspect_factory()
selfDeal = SelfDeal.self_deal_factory()
coordinatequery = Coordinate_query.coordinate_query_factory()
patrolmanagement = PatrolManagement.patrol_manage_factory()
disposecase = DisposeCase.dispose_case_factory()
dealHelper_instances = DisposeCase.DealHelper_Module()
evaluation = Comprehensive_Evaluation.comprehensive_evaluation_factory()
statistics_instances = Comprehensive_Evaluation.eGovaPluginStatistics()
personnelmonitor = Personnel_monitor.personnel_monitor_factory()
leaderassign = Leader_Assign.leader_assign_factory()
leader_assign_module_instances = Leader_Assign.leader_assign_module()
casesupervise = Case_Supervise.case_supervise_factory()
supervise_manager_instances = Case_Supervise.supervise_manager()
inspectorcheck = InspectorCheck.inspector_check_factory()
Contactor = contactor.contactor_factory()
reportevaluation = report_evaluation.report_evaluation_factory()
# supervisor_allocation = supervisor_allocation.supervisor_allocation_factory()
IllegalReporting = illegal_reporting.illegal_report_factory()
illegal_check = Illegal_Check.illegal_check_factory()
illegal_verification = Illegal_Verification.illegal_verification_factory()
illegal_patrol = Illegal_Patrol.illegal_patrol_factory()
resultOprate_instances = resultOprate.result_Operate()
resultOp_instances = resultOprate.result_Operate()
caseExcelOp = CaseExcelOperate.excel_Operate()

# base_dir = sys.path[0] + '/Result/'
# relative_address = userfulToolsFactory.creat_dir(userfulTool,base_dir)
# pic_file_path = base_dir + '/' + relative_address
# # pic_file_path = baseFupersonnel_monitor_factory()nctionInstance.set_pic_path()
#
# #初始化测试用例文件
# case_base_dir = sys.path[0] + '/Data/'
# case_name = 'TestCaesData.xlsx'
# test_case_file = case_base_dir + case_name
testcaselist = caseExcelOp.CaseDataOpreate(settings.test_case_file)
print testcaselist

class StartTest(unittest.TestCase):
    def StartTest(self):
        print 'StartTest'

class Login_eGovaMobile(unittest.TestCase):

    def set_server_url(self):
        print "test"
        login_factory.modify_server_address(loginDevices,baseInstance.driver,settings.server_url,settings.pic_file_path)
	
    def login_egova(self):
        print 'login'
        user_info = caseExcelOp.get_userInfo(settings.test_case_file,'Login_eGovaMobile')
        user_name = user_info[0]
        user_pwd = user_info[1]
        login_factory.login_system(loginDevices,baseInstance.driver,user_name,user_pwd,settings.pic_file_path)

    def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#消息列表查看
class message_case_assistant(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('message_case_assistant')

	def viwe_case_assistant(self):
		#打开案件处理助手
		print 'case_assistant'
		case_assistant.viwe_case_assistant(baseInstance.driver,settings.pic_file_path)

	def viwe_my_task(self):
		#打开我的任务
		print 'my_task'
		case_assistant.viwe_my_task(baseInstance.driver,settings.pic_file_path)

	def viwe_leader_assign(self):
		#打开领导交办
		print 'my_task'
		case_assistant.viwe_leader_assign(baseInstance.driver,settings.pic_file_path)
		
	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#今日提示
class scandaytip(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('scandaytip')

	def open_todaytip_plug(self):
		#打开今日提示
		todaytips.open_todaytip_plug(baseInstance.driver,settings.pic_file_path)

	def scan_tips(self):
		#查看提示
		todaytips.scan_tips(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)


class select_map_test(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('select_map_test')

	def open_mapselect_plug(self):
		#打开地图
		mapselect.open_mapselect_plug(baseInstance.driver,settings.pic_file_path)

	def Select_Map(self):
		#打开地图,拖动，并定位
		mapselect.Select_Map(baseInstance.driver,settings.pic_file_path)

	def full_map_function(self):
		#显示全图功能
		mapselect.full_map_function()

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#通用查询
class query(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('query')

	def open_generalquery_plug(self):
		#打开通用查询
		generalquery.open_generalquery_plug(baseInstance.driver,settings.pic_file_path)

	def query_case(self):
		#查询
		generalquery.query_case(baseInstance.driver,settings.pic_file_path)

	#通用查询结果检查
	def query_result_check(self):
		generalquery.query_result_check()

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#公文通告
class Annoucement(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Annoucement')

	def open_announcement_plug(self):
		#打开公文通告
		announcements.open_announcement_plug(baseInstance.driver,settings.pic_file_path)

	def scan_file(self):
		#查看通告
		announcements.scan_file(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#我的工作
class Mywork(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Mywork')

	def open_mywork_plug(self):
		#打开我的工作
		mywork.open_mywork_plug(baseInstance.driver,settings.pic_file_path)

	def punch_the_clock(self):
		#上下班打卡
		mywork.punch_the_clock(baseInstance.driver,settings.pic_file_path)

	def today_track(self):
		#轨迹回放
		mywork.today_track(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#问题上报
class NewReport(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('NewReport')

	def open_Report_plug(self):
		# 打开问题上报的插件
		newRecReport.open_Report_plug(baseInstance.driver,settings.pic_file_path)
	def open_NewReportUI(self):
		# 打开新问题上报界面
		newRecReport.open_NewReportUI(baseInstance.driver,settings.pic_file_path)
	def chose_event_type(self):
		# #选择问题类型、问题大小类
		newRecReport.chose_event_type(baseInstance.driver,settings.pic_file_path)
	def set_rec_desc(self):
		# # 输入“描述”内容
		newRecReport.set_rec_desc(baseInstance.driver,settings.pic_file_path)
	def set_Address_desc(self):
		# 选择"上报界面的位置定位按钮"
		newRecReport.set_Address_desc(baseInstance.driver,settings.pic_file_path)
	def choose_rec_pic(self):
		# # 从相册选取照片
		newRecReport.choose_rec_pic(baseInstance.driver,settings.pic_file_path)
	def new_rec_commit(self):
		# 进行提交并确认
		newRecReport.new_rec_commit(baseInstance.driver,settings.pic_file_path)
	def check_newRec_sucessful(self):
		# 判断是否上报成功--根据内容进行判断
		newRecReport.check_newRec_sucessful(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#我的任务
class Rec_Verify_Check(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Rec_Verify_Check')

	def open_Verify_Check_plug(self):
		#打开我的任务插件
		rec_verify_check.open_Verify_Check_plug(baseInstance.driver,settings.pic_file_path)

	def Verify_rec_task_filter(self):
		#筛选 --核实案件
		rec_verify_check.task_type_filter('verify')

	def Check_rec_task_filter(self):
		#筛选--核查按钮
		rec_verify_check.task_type_filter('check')

	def Verify_Rec_Task(self):
		#打开任务核实
		rec_verify_check_module_instances.Verify_Rec_Task()

	def Check_Rec_Task(self):
		#打开任务核查
		rec_verify_check_module_instances.Check_Rec_Task()

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#专项普查
class special_inspect(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('special_inspect')

	def open_inspect_plug(self):
		#打开专项普查插件
		specialinspect.open_inspect_plug(baseInstance.driver,settings.pic_file_path)

	def Census_Report(self):
		#打开专项普查插件
		specialinspect.Census_Report(baseInstance.driver,settings.pic_file_path)

	def scan_census_history(self):
		#打开专项普查插件
		specialinspect.scan_census_history(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#自行处置
class self_deal(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('self_deal')

	def open_selfdeal_plug(self):
		#打开自行处理插件
		selfDeal.open_selfdeal_plug(baseInstance.driver,settings.pic_file_path)

	def add_selfdeal_case(self):
		#添加自行处理案件
		selfDeal.add_selfdeal_case(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#违建上报
class Illegal_Report(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Illegal_Report')

	def open_illegalreport_plug(self):
		IllegalReporting.open_illegalreport_plug(baseInstance.driver,settings.pic_file_path)

	def add_case(self):
		IllegalReporting.add_case(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#坐标查询
class CoordinateQuery(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('CoordinateQuery')

	def open_coordinatequery_plug(self):
		#打开坐标查询
		coordinatequery.open_coordinatequery_plug(baseInstance.driver,settings.pic_file_path)

	def coordinate_query(self):
		#查询
		coordinatequery.coordinate_query(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#巡更管理
class patrol_management(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('patrol_management')

	def open_patrolmanagement_plug(self):
		#打开巡更管理
		patrolmanagement.open_patrolmanagement_plug(baseInstance.driver,settings.pic_file_path)

	def add_patrolmanage_case(self):
		#添加巡更管理案件
		patrolmanagement.add_patrolmanage_case(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#案件处置
class dispose_case(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('dispose_case')

	def open_disposecase_plug(self):
		#打开案件处理
		disposecase.open_disposecase_plug(baseInstance.driver,settings.pic_file_path)

	#案件筛选功能验证
	def deal_helper_filter(self):
		disposecase.deal_helper_filter()

	#返回功能列表
	def back_to_function_list(self):
		disposecase.back_to_function_list()

	def detail_case(self):
		#点击案件，查看详情
		dealHelper_instances.dealHelper_rec_detailInfor()

	def detail_case_map(self):
		#在案件详情页点击查看地图
		dealHelper_instances.dealHelper_detail_case_map()

	def detail_process_case(self):
		##查看办理进度
		dealHelper_instances.dealHelper_detail_process_case()

	def approve_case(self):
		#点击批转
		dealHelper_instances.dealHelper_rec_transit()

	def fall_back(self):
		#回退
		dealHelper_instances.dealHelper_rec_rollback()

	def urgency_case(self):
		#设为急事件
		dealHelper_instances.dealHelper_set_urgency()

	def suggestion_view(self):
		#查看意见
		dealHelper_instances.dealHelper_suggestion_view()

	def turn_to_send(self):
		#转派
		disposecase.turn_to_send(baseInstance.driver,settings.pic_file_path)

	def start_discuss(self):
		#发起讨论
		dealHelper_instances.dealHelper_start_discuss()

	def recovery_case(self):
		#恢复案件
		dealHelper_instances.dealHelper_rec_recovery()

	def register_case(self):
		#立案
		disposecase.register_case(baseInstance.driver,settings.pic_file_path)

	def Supervise_case(self):
		#督办
		disposecase.Supervise_case(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#综合评价
class com_evaluation(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('com_evaluation')

	def open_comprehensiveevaluation_plug(self):
		#打开综合评价
		evaluation.open_comprehensiveevaluation_plug()

	def statistics_first_statis(self):
		#综合评价--案件动态--根据类型查询
		statistics_instances.statistics_first_statis()

	def statistics_second_statis(self):
		# 综合评价--高发问题分组--问题分类统计（部件）
		statistics_instances.statistics_second_statis()

	def statistics_third_statis(self):
		# 综合评价--高发问题分组--问题分类统计（事件）
		statistics_instances.statistics_third_statis()

	def statistics_fourth_statis(self):
		# 综合评价--高发问题分组--事件高发（TOP5）
		statistics_instances.statistics_fourth_statis()

	def statistics_fifth_statis(self):
		# 综合评价--高发问题分组--部件高发（TOP5）
		statistics_instances.statistics_fifth_statis()

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#人员监控
class PersonnelMonitor(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('PersonnelMonitor')
	
	def open_personnelmonitor_plug(self):
		#打开人员监控
		personnelmonitor.open_personnelmonitor_plug(baseInstance.driver,settings.pic_file_path)

	def case_monitor(self):
		#查看案件监控
		personnelmonitor.case_monitor(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#领导交办
class  LeaderAssign(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('LeaderAssign')

	def open_leaderassign_plug(self):
		#打开领导交办
		leaderassign.open_leaderassign_plug(baseInstance.driver,settings.pic_file_path)

	def leaderTask_reply_function(self):
		#领导交办任务 回复功能
		leader_assign_module_instances.leaderTask_reply_function()

	def leaderTask_Forward_function(self):
		#打开领导交办,进行任务转发
		leader_assign_module_instances.leaderTask_Forward_function()

	def add_leader_assign(self):
		#添加领导交办
		leaderassign.add_leader_assign(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#案件督办
class CaseSupervise(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('CaseSupervise')

	def open_casesupervise_plug(self):
		#打开案卷督办
		casesupervise.open_casesupervise_plug()

	def urgent_rec_supervise(self):
		#急要件 -督办
		# casesupervise.case_supervise(baseInstance.driver,settings.pic_file_path)
		supervise_manager_instances.urgent_rec_supervise()

	def overtime_rec_supervise(self):
		#超时件 -督办
		# casesupervise.case_supervise(baseInstance.driver,settings.pic_file_path)
		supervise_manager_instances.overtime_rec_supervise()

	def suplist_rec_supervise(self):
		#督办件 -督办
		# casesupervise.case_supervise(baseInstance.driver,settings.pic_file_path)
		supervise_manager_instances.suplist_rec_supervise()

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#督查检查
class  inspector_check(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('inspector_check')
	
	def open_inspectorcheck_plug(self):
		#打开督察检查
		inspectorcheck.open_inspectorcheck_plug(baseInstance.driver,settings.pic_file_path) 

	def view_evaluation(self):
		#查看考评
		inspectorcheck.view_evaluation(baseInstance.driver,settings.pic_file_path) 

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#考评上报
class  Report_Evaluation(unittest.TestCase):
    #考评上报
	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Report_Evaluation')

	def open_report_evaluation_plug(self):
		reportevaluation.open_report_evaluation_plug(baseInstance.driver,settings.pic_file_path)

	def add_examination_report(self):
		reportevaluation.add_examination_report(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#联系人
class Contactor_test(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Contactor_test')

	def initiate_chat(self):
		#初始化聊天窗口
		Contactor.initiate_chat(baseInstance.driver,settings.pic_file_path)

	def chat_window(self):
		#进行聊天，发送表情、图片、文字
		Contactor.chat_window(baseInstance.driver,settings.pic_file_path) 

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#个人中心
class owner_test(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('owner_test')

	def open_owner(self):
		#打开个人中心
		print 'owner'
		owner_center.open_owner(baseInstance.driver,settings.pic_file_path)   
	def open_personal_information(self):
		# 个人信息设置
		owner_center.open_personal_information(baseInstance.driver,settings.pic_file_path)

	def speed_dial(self):
		#进入单键拨号	
		owner_center.speed_dial(baseInstance.driver,settings.pic_file_path)

	def function_manage(self):	
		#点击功能管理
		owner_center.function_manage(baseInstance.driver,settings.pic_file_path)	

	def function_setting(self):
		#点击功能设置
		owner_center.function_setting(baseInstance.driver,settings.pic_file_path)		

	def traffic_statistics(self):
		#打开流量统计
		owner_center.traffic_statistics(baseInstance.driver,settings.pic_file_path)

	def clear_cache(self):
		#清除缓存
		owner_center.clear_cache(baseInstance.driver,settings.pic_file_path)

	def drop_out(self):
		#点击退出
		owner_center.drop_out(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

	def re_login_newPassword(self):
		print '使用新密码重新登录'
		owner_center.re_login_newPassword()

class SupervisorAllocation(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app(baseInstance.driver,settings.pic_file_path)
	
	def open_supervisor_allocation_plug(self):
		# supervisor_allocation.open_supervisor_allocation_plug(baseInstance.driver,settings.pic_file_path)
		print u'暂时功能未知'

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#违建核实
class Illegal_Check(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Illegal_Check')

	def open_illegalcheck_plug(self):
		illegal_check.open_illegalcheck_plug(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#违建核查
class Illegal_Verification(unittest.TestCase):
		
	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('Illegal_Verification')
	def open_illegalverification_plug(self):
		illegal_verification.open_illegalverification_plug(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)

#违建巡检
class IllegalPatrol(unittest.TestCase):

	def lanuch_app(self):
		print 'lanuch app'
		lanuch_exit_app.lanuch_app(baseInstance.driver,settings.pic_file_path)

	def login_app(self):
		print 'login app'
		lanuch_exit_app.login_app('IllegalPatrol')

	def open_illegalpatrol_plug(self):
		illegal_patrol.open_illegalpatrol_plug(baseInstance.driver,settings.pic_file_path)

	def report_case(self):
		illegal_patrol.report_case(baseInstance.driver,settings.pic_file_path)

	def exit_app(self):
		print 'exit app'
		lanuch_exit_app.close_app(baseInstance.driver,settings.pic_file_path)


if __name__ == '__main__':

    suite = unittest.TestSuite()

    # case_base_dir = sys.path[0] + '/Data/'
    # case_name = 'TestCaesData.xlsx'
    # test_case_file = case_base_dir + case_name
    # testcaselist = caseExcelOp.CaseDataOpreate(case_base_dir + case_name)
    # print testcaselist

    for caseId in range(len(testcaselist)):
        testcase = testcaselist[caseId]
        # 根据实现的类名进行unittest的切换
        for case in BasePage.switch(testcase[0]):
            if case('Login_eGovaMobile'):
                suite.addTest(Login_eGovaMobile(testcase[1]))
            if case('message_case_assistant'):
                suite.addTest(message_case_assistant(testcase[1]))
            if case('scandaytip'):
                suite.addTest(scandaytip(testcase[1]))
            if case('select_map_test'):
                suite.addTest(select_map_test(testcase[1]))
            if case('query'):
                suite.addTest(query(testcase[1]))
            if case('Annoucement'):
                suite.addTest(Annoucement(testcase[1]))
            if case('Mywork'):
                suite.addTest(Mywork(testcase[1]))
            if case('NewReport'):
                suite.addTest(NewReport(testcase[1]))
            if case('Rec_Verify_Check'):
                suite.addTest(Rec_Verify_Check(testcase[1]))
            if case('special_inspect'):
                suite.addTest(special_inspect(testcase[1]))
            if case('self_deal'):
                suite.addTest(self_deal(testcase[1]))
            if case('CoordinateQuery'):
                suite.addTest(CoordinateQuery(testcase[1]))
            if case('patrol_management'):
                suite.addTest(patrol_management(testcase[1]))
            if case('dispose_case'):
                suite.addTest(dispose_case(testcase[1]))
            if case('com_evaluation'):
                suite.addTest(com_evaluation(testcase[1]))
            if case('PersonnelMonitor'):
                suite.addTest(PersonnelMonitor(testcase[1]))
            if case('LeaderAssign'):
                suite.addTest(LeaderAssign(testcase[1]))
            if case('CaseSupervise'):
                suite.addTest(CaseSupervise(testcase[1]))
            if case('inspector_check'):
                suite.addTest(inspector_check(testcase[1]))
            if case('Report_Evaluation'):
                suite.addTest(Report_Evaluation(testcase[1]))
            if case('SupervisorAllocation'):
                suite.addTest(SupervisorAllocation(testcase[1]))
            if case('Illegal_Report'):
                suite.addTest(Illegal_Report(testcase[1]))
            if case('Illegal_Check'):
                suite.addTest(Illegal_Check(testcase[1]))
            if case('Illegal_Verification'):
                suite.addTest(Illegal_Verification(testcase[1]))
            if case('IllegalPatrol'):
                suite.addTest(IllegalPatrol(testcase[1]))
            if case('Contactor_test'):
                suite.addTest(Contactor_test(testcase[1]))
            if case('owner_test'):
                suite.addTest(owner_test(testcase[1]))
        # 添加报告名称和地址
	filename = settings.base_dir + '/Result/egova-test-' + settings.relative_address + '.html'
	result_file = settings.base_dir + '/Result/egova-test-' + settings.relative_address + '.xls'
    print filename
    fp = file(filename, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp,
            title='result',
            description='report'
        )
    runner.run(suite)
    fp.close()

    result_list = resultOp_instances.get_result(testcaselist, filename)
    print result_list
    caseExcelOp.update_case_result(result_list, settings.test_case_file, result_file)
    caseExcelOp.set_excel_format(result_file)

    unittest.main(2)





